﻿<Window x:Class="DataBinding.Sorting"
    xmlns:local="clr-namespace:DataBinding"
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Sorting" Height="145" Width="283">
    <Window.Resources>
        <CollectionViewSource Source="{x:Static local:Data.People}" x:Key="cvs">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription PropertyName="LastName" />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
    </Window.Resources>
    <Grid>
        <ListBox ItemsSource="{Binding Source={StaticResource cvs}}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Path=FirstName}" FontSize="16" />
                        <TextBlock Text="{Binding Path=LastName}"  FontSize="16" Margin="3.5,0,7,0" />
                        <TextBlock Text="{Binding Path=Birthday, StringFormat=d}" FontSize="16" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Window>
